#include <iostream>
#include <map>
#include <cctype>
#include <algorithm>
using namespace std;

typedef map <char, int> Map;
typedef Map::iterator Iterator;


struct Key
{
	char l;
	int c;
};


bool operator < (const Key &k1, const Key &k2)
{
	return ( k1.c == k2.c ) ? ( k1.l < k2.l ) : ( k1.c > k2.c );
}


Map m;
Key key[256], *last_key;


bool read ()
{
	char c;
	m.clear();
	while( cin.get( c ), c != '\n' )
	{
		if( cin.fail() )
			return false;
		if( isalpha( c ) )
			++m[c];
	}
	return true;
}


void process ()
{
	Iterator it;
	last_key = key;
	for( it = m.begin(); it != m.end(); ++it )
	{
		last_key->l = it->first;
		last_key->c = it->second;
		++last_key;
	}

	sort( key, last_key );
	cout << key->l;
	for( Key *k = key + 1; k != last_key; ++k )
	{
		if( k->c == key->c)
			cout << k->l;
		else
			break;
	}
	cout << ' ' << key->c << '\n';
}


int main ()
{
	while( read() )
		process();
	return 0;
}